﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace PersonalAlbum
{
    public class ValidateCaptchaAttribute:ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (ConfigManager.UseCaptcha)
            {
                if (!CaptchaManager.IsValid)
                {
                    filterContext.Result= Utils.JavascriptError(ObjectFactory.GetInstance<ILanguageService>().GetText("Global.InvalidCaptcha"));
                    
                    return;
                }
            }
            base.OnActionExecuting(filterContext);
        }
    }
}
